<template>
    <div id="order-manage">
        <div class="title">
            <h1>用户列表</h1>
        </div>
        <div class="searchInfo">
            <el-form  :model="search_Data" label-width="80px" size="medium" :label-position="labelPosition"
            style="text-align:right ;"
            >
                <div class="search_col_top">
                    <el-form-item label="开始时间">
                        <el-date-picker type="date" placeholder="选择开始日期" v-model="search_Data.startDate"
                            style="width: 150px" value-format="yyyy-MM-dd" clearable></el-date-picker>
                    </el-form-item>
                    <el-form-item label="结束时间">
                        <el-date-picker type="date" label-width="50px" placeholder="选择结束日期"
                            v-model="search_Data.endDate" style="width: 150px" clearable value-format="yyyy-MM-dd">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="用户ID">
                        <el-input v-model="search_Data.id" style="width: 130px" clearable>
                        </el-input>
                    </el-form-item>
                    <el-form-item label="用户名称">
                        <el-input v-model="search_Data.name" style="width: 130px" clearable>
                        </el-input>
                    </el-form-item>
                    <el-form-item label="手机号">
                        <el-input v-model="search_Data.tel" style="width: 130px" clearable>
                        </el-input>
                    </el-form-item>
                    <el-button type="info" @click="onSearchBtn">查询</el-button>
                </div>
            </el-form>

        </div>
        <!-- 表格 -->
        <el-table :data="tableData" tooltip-effect="dark" style="width: 100%;line-height: 0; margin-top: 20px;" row-key="id">
            <el-table-column prop="id" label="用户ID" width="80px" align="left">
            </el-table-column>
            <el-table-column prop="name" label="用户名称" align="center">
            </el-table-column>
            <el-table-column prop="tel" label="用户手机号" align="center" width="180" >
            </el-table-column>
            <el-table-column prop="registrationTime" label="用户注册时间" align="center">
            </el-table-column>
            <el-table-column prop="account" label="账户余额" align="center">
            </el-table-column>
            <el-table-column prop="studyTime" label="累计学习时长" align="center">
            </el-table-column>
            <el-table-column prop="exchangeTime" label="可用兑换时长" align="center">
            </el-table-column>
            <el-table-column fixed="right" label="点击查看" width="100" align="center">
                <template slot-scope="scope">
                    <el-button @click="UserCard(scope.row)" type="text" size="small">用户卡卷</el-button>
                    <el-button @click="ClockRecords(scope.row)" type="text" size="small">打卡记录</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination 
            style="float:right" 
            @current-change="handleCurrentChange" 
            :current-page.sync="page"
            :page-size="limit" 
            layout="prev, pager, next" 
            :total="total">
        </el-pagination>
    </div>
</template>

<script>
// import ClockRecords from './ClockRecords.vue';

export default {
    data() {
        return {
            labelPosition: "center",
            // order_state: '',
            search_Data: {
                startDate: null,
                endDate: null,
                id: null,
                tel: null,
                name:null,
            },
            tableData: [{
                list:[]
            }
            ],
            total:null,
            page:1,
            limit:5,
            pageSize:null,
        }
    },
    methods: {
        getData:function(){
            this.$axios({
                url:'/user',
                method:'get',
                params:{
                    page:this.page,
                    limit:this.limit,
                    id:this.search_Data.id,
                    name:this.search_Data.name,
                    startDate:this.search_Data.startDate,
                    endDate:this.search_Data.endDate,
                    tel:this.search_Data.tel
                }
            }).then(({data})=>{
                this.tableData=data.data.list
                this.total=data.data.totalCount
            })
        },
        // 查询按钮
        onSearchBtn() {
            this.getData()
        },
        // 用户卡券
        UserCard(row) {
            this.userId=row.id,
            this.userTel=row.tel,
            this.$router.push({path:'/home/UserCard',query:{id:this.userId,tel:this.userTel}})
        },
        ClockRecords(row){
            this.userId=row.id,
            this.userTel=row.tel
            this.$router.push({path:'/home/ClockRecords',query:{id:this.userId,tel:this.userTel}})
        },
        handleCurrentChange (v) {
            this.page=v,
            this.getData()
        },
        
    },
    mounted: function () {
    this.getData();
  },
    
}
</script>


<style scoped lang="less">
#order-manage {
    width: 100%;
    height: 100%;
    // outline: 1px solid red;

    &>.title {
        line-height: 0;
        text-align: left;
    }
    & .searchInfo {
        width: 100%;
        height: 50px;
        background: #d7d7d7;
        margin-top: 30px;
        padding-left: 10px;
        box-sizing: border-box;
        position: relative;
        min-width: 1440px;

        & .search_col_top {
            width: 100%;
            height: 50px;
            display: flex;
            align-items: center;
        }

        .el-form {
            height: 50px;
        }

        .el-form-item {
            margin-bottom: 0;
        }

        .el-form-item__label {
            padding-left: 20px;
        }

        .el-button {
            position: absolute;
            right: 200px;
        }

        .el-form-item__label {
            text-align: center;
            vertical-align: middle;
            float: left;
            font-size: 14px;
            color: #606266;
            line-height: 40px;
            /* padding: 0 12px 0 0; */
            box-sizing: border-box;
        }


    }

    


}
</style>